//	Project:	HexTower
//	File:		HUD.cpp
//	Author:		Mustafa Aldoori
//	Purpose:	HUD Class implementation.

#include "HUD.h"
#include "Cursor.h"
#include "Direct3D_Manager.h"
#include "DirectGraphics_Manager.h"
#include "DirectInput_Manager.h"

CHUD* CHUD::GetInstance()
{
	static CHUD hud;

	return &hud;
}

CHUD::CHUD( void )
{
	nHighlightMenu = -1;
	nSelectedMenu = -1;


}

CHUD::~CHUD( void )
{

}

void CHUD::Init()
{
	m_pD3D			=	Direct3D_Manager::GetInstance();
	m_pGM			=	DirectGraphics_Manager::GetInstance();
	m_pDI			=	DirectInput_Manager::GetInstance();
	m_pCC			=	CCursor::GetInstance();

	nMenu_LobbyID = m_pGM->LoadTexture( _T( "Resources/Graphics/Menu_Lobby.png" ) );
	nMenu_WreckID = m_pGM->LoadTexture( _T( "Resources/Graphics/Menu_Wreck.png" ) );

	
}

void CHUD::Render()
{
	m_pGM->Draw( nMenu_LobbyID, 32, 64, 1.0f, 1.0f, nullptr, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB( 155, 255, 255, 255 ) ); 
	m_pGM->Draw( nMenu_WreckID, 100, 64, 1.0f, 1.0f, nullptr, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB( 155, 255, 255, 255 ) ); 

	RECT tRect = {};

	switch( nHighlightMenu )
	{
	case 1:
		tRect.top = 62;	tRect.left = 30;
		tRect.right = 98; tRect.bottom = 130;
		m_pD3D->DrawRect( tRect, 255,255,255 );

		break;
	case 2:
		tRect.top = 62; tRect.left = 98;
		tRect.right = 166; tRect.bottom = 130;
		m_pD3D->DrawRect( tRect, 255,255,255 );

		break;
	case 3:

		break;
	default:
		break;
	}

	switch( nSelectedMenu )
	{
	case 1:
		tRect.top = 62;	tRect.left = 30;
		tRect.right = 98; tRect.bottom = 130;
		m_pD3D->DrawRect( tRect, 255,0,0 );

		break;
	case 2:
		tRect.top = 62; tRect.left = 98;
		tRect.right = 166; tRect.bottom = 130;
		m_pD3D->DrawRect( tRect, 255,0,0 );

		break;
	case 3:

		break;
	default:
		break;
	}

}

void CHUD::Input( )
{
	if( m_pCC->GetCursorXPosition() >= 32 && m_pCC->GetCursorXPosition() <= 96 &&
		m_pCC->GetCursorYPosition() >= 64 && m_pCC->GetCursorYPosition() <= 128 )
	{
		nHighlightMenu = 1;
		if( m_pDI->MouseButtonPressed( 0 ) )
		{
			nSelectedMenu = 1;
		}
	}
	else if( m_pCC->GetCursorXPosition() >= 100 && m_pCC->GetCursorXPosition() <= 164 &&
		m_pCC->GetCursorYPosition() >= 64 && m_pCC->GetCursorYPosition() <= 128 )
	{
		nHighlightMenu = 2;
		if( m_pDI->MouseButtonPressed( 0 ) )
		{
			nSelectedMenu = 2;
		}
	}
	else
	{
		nHighlightMenu = 0;
	}
}